#pragma once
#include <list>
#include "mapss.h"
using namespace std;

typedef Mapss Row;
class Result : public list<Row>
{
public:
	inline void get(int count, char **name, char **value);
	inline string toString(void)const{return data();}
	inline string str(void)const{return data();}
	inline string data(void)const;
};
inline void Result::get(int count, char **name, char **value)
{
	if(count > 0 && name && value && *name && *value)
	{
		this->push_back(Row());
		Row& row = this->back();

		for(int i = 0; i < count && name[i] && value[i]; i++)
		{
			row[name[i]] << value[i];
		}
	}
}
inline string Result::data(void)const
{
	int i = 0;
	sstream ss;

	for(const_iterator A = begin(); A != end(); A++)
	{
		ss << i++ << ": ";
		for(Row::const_iterator B = A->begin(); B != A->end(); B++)
		{
			//ss << "[" << B->first << "]=" << B->second.str() << endl;
		}
		ss << A->str();
		ss << endl;
	}
	return ss.str();
}
